package com.tuanbiao.models.action;

import androidx.annotation.NonNull;

import com.hzjq.data.callback.OnResultCallback;
import com.hzjq.data.entity.ACapEntity;
import com.hzjq.lib.BlastKool;
import com.tuanbiao.data.callback.OnBaseResultCallback;

import java.util.List;

/**
 * @author abiao
 * @since 2022/4/27 10:35
 */
public interface SingleCheckAction {
    default void querySingleDetonators(int pageIndex, OnBaseResultCallback<List<ACapEntity>> callback) {
        BlastKool.Companion.loader().db().queryACaps(pageIndex, aCapEntities -> {
            callback.onSuccess(aCapEntities);
            callback.onFinish();
        });
    }

    default void deleteSingleDetonators(ACapEntity entity, OnBaseResultCallback<Void> callback) {
        BlastKool.Companion.loader().db().deleteACap(entity, () -> {
            callback.onSuccess(null);
            callback.onFinish();
        });
    }

    default void deleteSingleDetonators(List<ACapEntity> entities, OnBaseResultCallback<Void> callback) {
        BlastKool.Companion.loader().db().deleteACapAll(entities, () -> {
            callback.onSuccess(null);
            callback.onFinish();
        });
    }

    default void clearSingleDetonators(OnBaseResultCallback<Void> callback) {
        BlastKool.Companion.loader().db().clearACap(() -> {
            callback.onSuccess(null);
            callback.onFinish();
        });
    }

    default void singleDetonatorCheck(OnBaseResultCallback<ACapEntity> callback) {
        BlastKool.Companion.loader().capCheck().check(new OnResultCallback<ACapEntity>() {
            @Override
            public void onResult(ACapEntity aCapEntity) {
                callback.onSuccess(aCapEntity);
                callback.onFinish();
            }

            @Override
            public void onFailed(@NonNull String s) {
                callback.onFailed(s);
                callback.onFinish();
            }
        });
    }
}
